home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / VideoFolder 1.0a / Source / MoreFiles 1.4.1 / MoreDesktopMgr.p < prev    next >
Text File  |  1995-12-21  |  10KB  |  242 lines

  1. UNIT MoreDesktopMgr;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    A collection of useful high-level Desktop Manager routines.                }
  6. {    If the Desktop Manager isn't available, use the Desktop file            }
  7. {    for 'read' operations.                                                    }
  8. {                                                                            }
  9. {    We do more because we can...                                            }
  10. {                                                                            }
  11. {    by Jim Luther and Nitin Ganatra,                                        }
  12. {        Apple Developer Technical Support Emeriti                            }
  13. {                                                                            }
  14. {    File:        MoreDesktopMgr.p                                            }
  15. {                                                                            }
  16. {    Copyright © 1992-1995 Apple Computer, Inc.                                }
  17. {    All rights reserved.                                                    }
  18. {                                                                            }
  19. {    You may incorporate this sample code into your applications without        }
  20. {    restriction, though the sample code has been provided "AS IS" and the    }
  21. {    responsibility for its operation is 100% yours.  However, what you are    }
  22. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  23. {    after having made changes. If you're going to re-distribute the source,    }
  24. {    we require that you make it clear in the source that the code was        }
  25. {    descended from Apple Sample Code, but that you've made changes.            }
  26.  
  27.  
  28. INTERFACE
  29.  
  30. USES
  31.     Files;
  32.  
  33. {***************************************************************************}
  34.  
  35.  
  36.     FUNCTION DTOpen (volName: StringPtr;
  37.                                     vRefNum: Integer;
  38.                                     VAR dtRefNum: Integer;
  39.                                     VAR newDTDatabase: Boolean): OSErr;
  40. {    The DTOpen function opens a volume's desktop database. It returns        }
  41. {    the reference number of the desktop database and indicates if the        }
  42. {    desktop database was created as a result of this call (if it was        }
  43. {    created, then it is empty).                                                }
  44. {                                                                            }
  45. {    volName            input:    A pointer to the name of a mounted volume        }
  46. {                            or nil.                                            }
  47. {    vRefNum            input:    Volume specification.                            }
  48. {    dtRefNum        output:    The reference number of Desktop Manager's        }
  49. {                            desktop database on the specified volume.        }
  50. {    newDTDatabase    output:    true if the desktop database was created as a    }
  51. {                            result of this call and thus empty.                }
  52. {                            false if the desktop database was already        }
  53. {                            created, or if it could not be determined if it    }
  54. {                            was already created.                            }
  55.  
  56.  
  57. {***************************************************************************}
  58.  
  59.  
  60.     FUNCTION DTGetAPPL (volName: StringPtr;
  61.                                     vRefNum: Integer;
  62.                                     creator: OSType;
  63.                                     VAR applVRefNum: Integer;
  64.                                     VAR applParID: LongInt;
  65.                                     VAR applName: Str255): OSErr;
  66. {    The DTGetAPPL function finds an application (file type 'APPL') with        }
  67. {    the specified creator on the specified volume. It first tries to get    }
  68. {    the application mapping from the desktop database. If that fails, then    }
  69. {    it tries to find an application with the specified creator using        }
  70. {    the File Manager's CatSearch routine. If that fails, then it tries to    }
  71. {    find an application in the Desktop file.                                }
  72. {                                                                            }
  73. {    volName        input:    A pointer to the name of a mounted volume            }
  74. {                        or nil.                                                }
  75. {    vRefNum        input:    Volume specification.                                }
  76. {    creator        input:    The file's creator type.                            }
  77. {    applVRefNum    output:    The volume reference number of the volume the        }
  78. {                        application is on.                                    }
  79. {    applParID    output:    The parent directory ID of the application.            }
  80. {    applName    output:    The name of the application.                        }
  81.  
  82.  
  83. {***************************************************************************}
  84.  
  85.  
  86.     FUNCTION FSpDTGetAPPL (volName: StringPtr;
  87.                                     vRefNum: Integer;
  88.                                     creator: OSType;
  89.                                     VAR spec: FSSpec): OSErr;
  90. {    The FSpDTGetAPPL function finds an application (file type 'APPL') with    }
  91. {    the specified creator on the specified volume. It first tries to get    }
  92. {    the application mapping from the desktop database. If that fails, then    }
  93. {    it tries to find an application with the specified creator using        }
  94. {    the File Manager's CatSearch routine. If that fails, then it tries to    }
  95. {    find an application in the Desktop file.                                }
  96. {                                                                            }
  97. {    volName        input:    A pointer to the name of a mounted volume            }
  98. {                        or nil.                                                }
  99. {    vRefNum        input:    Volume specification.                                }
  100. {    creator        input:    The file's creator type.                            }
  101. {    spec        output:    FSSpec record containing the application name and    }
  102. {                        location.                                            }
  103.  
  104.  
  105. {***************************************************************************}
  106.  
  107.  
  108.     FUNCTION DTGetIcon (volName: StringPtr;
  109.                                     vRefNum: Integer;
  110.                                     iconType: Integer;
  111.                                     fileCreator: OSType;
  112.                                     fileType: OSType;
  113.                                     VAR iconHandle: Handle): OSErr;
  114. {    The DTGetIcon function retrieves the specified icon and returns it in    }
  115. {    a newly created handle. The icon is retrieves from the Desktop Manager    }
  116. {    or if the Desktop Manager is not available, from the Finder's Desktop    }
  117. {    file. Your program is responsible for disposing of the handle when it    }
  118. {    is done using the icon.                                                    }
  119. {                                                                            }
  120. {    volName        input:    A pointer to the name of a mounted volume            }
  121. {                        or nil.                                                }
  122. {    vRefNum        input:    Volume specification.                                }
  123. {    iconType    input:    The icon type as defined in Files.h. Valid values    }
  124. {                        are:                                                }
  125. {                            kLargeIcon                                        }
  126. {                            kLarge4BitIcon                                    }
  127. {                            kLarge8BitIcon                                    }
  128. {                            kSmallIcon                                        }
  129. {                            kSmall4BitIcon                                    }
  130. {                            kSmall8BitIcon                                    }
  131. {    fileCreator    input:    The icon's creator type.                            }
  132. {    fileType    input:    The icon's file type.                                }
  133. {    iconHandle    output:    A Handle containing the newly created icon.            }
  134.  
  135.  
  136. {***************************************************************************}
  137.  
  138.  
  139.     FUNCTION DTSetComment (vRefNum: Integer;
  140.                                     dirID: LongInt;
  141.                                     name: StringPtr;
  142.                                     comment: Str255): OSErr;
  143. {    The DTSetComment function sets a file or directory's Finder comment        }
  144. {    field. The volume must support the Desktop Manager because you only        }
  145. {    have read access to the Desktop file.                                    }
  146. {                                                                            }
  147. {    vRefNum    input:    Volume specification.                                    }
  148. {    dirID    input:    Directory ID.                                            }
  149. {    name    input:    Pointer to object name, or nil when dirID                }
  150. {                    specifies a directory that's the object.                }
  151. {    comment    input:    The comment to add. Comments are limited to 200            }
  152. {                    characters; longer comments are truncated.                }
  153.  
  154.  
  155. {***************************************************************************}
  156.  
  157.  
  158.     FUNCTION FSpDTSetComment ({CONST}VAR spec: FSSpec;
  159.                                     comment: Str255): OSErr;
  160. {    The FSpDTSetComment function sets a file or directory's Finder comment    }
  161. {    field. The volume must support the Desktop Manager because you only        }
  162. {    have read access to the Desktop file.                                    }
  163. {                                                                            }
  164. {    spec    input:    An FSSpec record specifying the file or directory.        }
  165. {    comment    input:    The comment to add. Comments are limited to 200            }
  166. {                    characters; longer comments are truncated.                }
  167.  
  168.  
  169. {***************************************************************************}
  170.  
  171.  
  172.     FUNCTION DTGetComment (vRefNum: Integer;
  173.                                     dirID: LongInt;
  174.                                     name: StringPtr;
  175.                                     VAR comment: Str255): OSErr;
  176. {    The DTGetComment function gets a file or directory's Finder comment        }
  177. {    field (if any) from the Desktop Manager or if the Desktop Manager is    }
  178. {    not available, from the Finder's Desktop file.                            }
  179. {                                                                            }
  180. {    vRefNum    input:    Volume specification.                                    }
  181. {    dirID    input:    Directory ID.                                            }
  182. {    name    input:    Pointer to object name, or nil when dirID                }
  183. {                    specifies a directory that's the object.                }
  184. {    comment    output:    A Str255 where the comment is to be returned.            }
  185.  
  186.  
  187. {***************************************************************************}
  188.  
  189.  
  190.     FUNCTION FSpDTGetComment ({CONST}VAR spec: FSSpec;
  191.                                     VAR comment: Str255): OSErr;
  192. {    The FSpDTGetComment function gets a file or directory's Finder comment    }
  193. {    field (if any) from the Desktop Manager or if the Desktop Manager is    }
  194. {    not available, from the Finder's Desktop file.                            }
  195. {                                                                            }
  196. {    spec    input:    An FSSpec record specifying the file or directory.        }
  197. {    comment    output:    A Str255 where the comment is to be returned.            }
  198.  
  199.  
  200. {***************************************************************************}
  201.  
  202.  
  203.     FUNCTION DTCopyComment (srcVRefNum: Integer;
  204.                                     srcDirID: LongInt;
  205.                                     srcName: StringPtr;
  206.                                     dstVRefNum: Integer;
  207.                                     dstDirID: LongInt;
  208.                                     dstName: StringPtr): OSErr;
  209. {    The DTCopyComment function copies the file or folder comment from the    }
  210. {    source to the destination object.  The destination volume must support    }
  211. {    the Desktop Manager because you only have read access to the Desktop    }
  212. {    file.                                                                    }
  213. {                                                                            }
  214. {    srcVRefNum    input:    Source volume specification.                        }
  215. {    srcDirID    input:    Source directory ID.                                }
  216. {    srcName        input:    Pointer to source object name, or nil when srcDirID    }
  217. {                        specifies a directory that's the object.            }
  218. {    dstVRefNum    input:    Destination volume specification.                    }
  219. {    dstDirID    input:    Destination directory ID.                            }
  220. {    dstName        input:    Pointer to destination object name, or nil when        }
  221. {                        dstDirID specifies a directory that's the object.    }
  222.  
  223.  
  224. {***************************************************************************}
  225.  
  226.  
  227.     FUNCTION FSpDTCopyComment ({CONST}VAR srcSpec: FSSpec;
  228.                                     {CONST}VAR dstSpec: FSSpec): OSErr;
  229. {    The FSpDTCopyComment function copies the desktop database comment from    }
  230. {    the source to the destination object.  Both the source and the            }
  231. {    destination volumes must support the Desktop Manager.                    }
  232. {                                                                            }
  233. {    srcSpec        input:    An FSSpec record specifying the source object.        }
  234. {    dstSpec        input:    An FSSpec record specifying the destination object.    }
  235.  
  236.  
  237. {***************************************************************************}
  238.  
  239.  
  240. IMPLEMENTATION
  241.  
  242. END.